package com.bestcem.xm.award.job;

import cn.hutool.core.date.DateUtil;
import com.bestcem.xm.award.service.AwardStatsService;
import com.bestcem.xm.componet.xxljob.annotation.XxlRegister;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @ClassName: AwardStatsDayJobService
 * @Description: 奖励请求统计定时任务
 * @Author: chenglong.yue
 * @Date: 2023/3/31 15:50
 */
@Component
public class AwardStatsDayJobService {

    private static final Logger logger = LoggerFactory.getLogger(AwardStatsDayJobService.class);

    @Resource
    private AwardStatsService awardStatsService;

    @XxlJob(value = "award-awardStatsDay-job", init = "init", destroy = "destroy")
    //@XxlRegister(cron = "0 * * * * ?", triggerStatus = 1, jobDesc = "奖励请求统计定时任务")
    @XxlRegister(cron = "${app.award.task.mqCron:0 * * * * ?}", triggerStatus = 1, jobDesc = "奖励请求统计定时任务")
    public void job() {
        awardStatsService.dailyRequestStats(DateUtil.yesterday());
    }

    public void init() {
        logger.info("award-awardStatsDay-job init");
    }

    public void destroy() {
        logger.info("award-awardStatsDay-job destroy");
    }
}
